﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using He.Web.UI;

namespace He.Web.Tools
{
    /// <summary>
    /// Ajax 的摘要说明
    /// </summary>
    public class Ajax : He.Web.UI.AjaxHandler
    {

        public override void ProcessRequest(HttpContext context)
        {
            string action = context.Request["act"];

            #region //===================产品搜索======================
            int cid = 2;
            string q = InputUtil.Get("q");
            int top = InputUtil.Get("limit",0);
            DataTable dt = new He.BLL.article().GetList(cid, top, "Title like '%" + q + "%' and category_id in (select Id from he_category where channel_id=2)", "SortId asc,Id desc").Tables[0];

            string JosnString = "[";
            foreach (DataRow dr in dt.Rows)
            {
                if (JosnString == "[")
                {
                    JosnString += "{title:\"" + dr["Title"].ToString() + "\"}";
                }
                else
                {
                    JosnString += ",{title:\"" + dr["Title"].ToString() + "\"}";
                }
            }
            JosnString += "]";
            context.Response.Write(JosnString);
            context.Response.End();
            #endregion
        }

        public override bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}